import { relations } from "drizzle-orm/relations";
import { qrtzTriggers, qrtzBlobTriggers, qrtzCronTriggers, qrtzSimpleTriggers, qrtzSimpropTriggers, qrtzJobDetails } from "../../drizzle/schema";

export const qrtzBlobTriggersRelations = relations(qrtzBlobTriggers, ({one}) => ({
	qrtzTrigger: one(qrtzTriggers, {
		fields: [qrtzBlobTriggers.schedName],
		references: [qrtzTriggers.schedName]
	}),
}));

export const qrtzTriggersRelations = relations(qrtzTriggers, ({one, many}) => ({
	qrtzBlobTriggers: many(qrtzBlobTriggers),
	qrtzCronTriggers: many(qrtzCronTriggers),
	qrtzSimpleTriggers: many(qrtzSimpleTriggers),
	qrtzSimpropTriggers: many(qrtzSimpropTriggers),
	qrtzJobDetail: one(qrtzJobDetails, {
		fields: [qrtzTriggers.schedName],
		references: [qrtzJobDetails.schedName]
	}),
}));

export const qrtzCronTriggersRelations = relations(qrtzCronTriggers, ({one}) => ({
	qrtzTrigger: one(qrtzTriggers, {
		fields: [qrtzCronTriggers.schedName],
		references: [qrtzTriggers.schedName]
	}),
}));

export const qrtzSimpleTriggersRelations = relations(qrtzSimpleTriggers, ({one}) => ({
	qrtzTrigger: one(qrtzTriggers, {
		fields: [qrtzSimpleTriggers.schedName],
		references: [qrtzTriggers.schedName]
	}),
}));

export const qrtzSimpropTriggersRelations = relations(qrtzSimpropTriggers, ({one}) => ({
	qrtzTrigger: one(qrtzTriggers, {
		fields: [qrtzSimpropTriggers.schedName],
		references: [qrtzTriggers.schedName]
	}),
}));

export const qrtzJobDetailsRelations = relations(qrtzJobDetails, ({many}) => ({
	qrtzTriggers: many(qrtzTriggers),
}));